<template>
	<!---->
	<view class=" mybtns tn-safe-area-inset-bottom">
		<view class="bottom-btn" :style="'margin-bottom:'+bottom+'rpx'">
			<!-- <view v-if="auth.FEdit==1 &&status==''" class="tn-bg-orange edit btn" @click="edit">
				修改
			</view> -->
			<!-- show{{show}} -->
			<view class=" btn">
				<print-btn label="全部打印" v-bind="$attrs" :auth="auth"></print-btn>
			</view>

			<view v-if="(status=='0' || !status) && auth.meta.type =='VIEW'"
				:class="auth.FAudit==1? 'tn-bg-orange ':'tn-bg-gray'" class="verify btn" @click="verify">
				审批
			</view>
			<!-- auth{{auth.meta.type}}  status:{{status=='0'}} -->
			<view v-if="auth.FAdd==1 && (status=='0' || !status)  && auth.meta.type =='ADD'" class="tn-bg-blue save btn"
				@click="save">
				保存
			</view>
			<view>
				<slot></slot>
			</view>
		</view>
	</view>


</template>

<script>
	import {
		mapState,
		mapGetters,
		mapActions
	} from 'vuex';
	export default {
		name: "bottombtn",
		data() {
			return {
				auth: {},
				// show: false,
				FItemId: this.$storage.getStorageSync('FItemId'),
			};
		},
		components: {

		},
		props: {
			status: {
				type: String,
				default () {
					return ''
				}
			},

			bottom: {
				type: String,
				default () {
					return '20'
				}
			},
			// pdata: {
			// 	type: Object,
			// 	default () {
			// 		return {};
			// 	}
			// }
		},
		computed: {
			show() {
				console.log('this.auth', this.auth)
				return this.auth.FPrint == '1' || this.auth.meta.type == 'VIEW' || this.auth.meta.type == 'ADD'
			}
		},
		watch: {
			FItemId: {
				handler(newv, old) {
					this.auth = this.$user.getAuth(newv)
				},
				immediate: true,
			}
		},

		mounted() {
			console.log('bottom-bar FItemId组件已加载完成！', this.FItemId);
		},

		beforeDestroy() {

		},
		methods: {
			edit() {
				this.$emit('edit')
			},
			verify() {
				if (this.auth.FAudit == 0) {
					uni.showToast({
						title: '没有权限，请联系管理员',
						icon: 'none'
					})
					return false;
				}
				this.$emit('verify')
			},
			print() {
				this.$emit('print')
			},
			save() {
				this.$emit('save')
			},
		}
	}
</script>

<style scoped lang="scss">
	.mybtns {
		position: fixed;
		bottom: 0;
		width: 100%;
		left: 0;
		text-align: center;
		z-index: 99;
		background: #fff;
		padding-top: 20rpx
	}

	.bottom-btn {
		height: 88rpx;
		text-align: center;
		display: flex;
		// color: #FFFFFF;

	}

	.btn {
		flex: 1;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		height: 77rpx;
		border-radius: 10rpx;
		margin: 0 10px;
		color: #fff
	}
</style>